package Day5;

public class animal {
    public static void main( String[] args ) {
        Cat cat = new Cat();
        cat.setData("菲丽斯",21);
        cat.getData();

        Dog dog = new Dog();
        dog.setData("孙文迪",20);
        dog.getData();
        dog.voice();

    }
}
class Animal{
    private String name;

    private int age;

    public void setData (String name, int age) {
        this.name = name;
        this.age = age;
    }

    // 获取名称
    public String getName() {
        return name;
    }

    // 获取年龄
    public int getAge() {
        return age;
    }
}
class Cat extends Animal{
    public void voice () {
        System.out.println("喵~");
    }
    public void eat () {
        System.out.println("吃fish");
    }
    public void getData () {
        System.out.println(getName() + "," + getAge());
    }
}
class Dog extends Animal{
    public void voice () {
        System.out.println("卧槽，我怎么噶了");
    }
    public void eat () {
        System.out.println("狗改不了吃（）");
    }

    public void getData () {
        System.out.println(getName() + "," + getAge());
    }
}
